package com.ruoyi.system.controller;

import com.github.pagehelper.PageInfo;
import com.ruoyi.common.core.constant.HttpStatus;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.system.api.model.LoginUser;
import com.ruoyi.system.domain.SysUserScok;
import com.ruoyi.system.service.SysUserScokService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

import static com.ruoyi.common.core.utils.PageUtils.startPage;
import static com.ruoyi.common.core.web.domain.AjaxResult.success;
import static com.ruoyi.common.security.utils.SecurityUtils.getLoginUser;

@RestController
@RequestMapping("/mystock")
public class SysMyscokController {
    @Autowired
    private SysUserScokService userScokService;
    @Autowired
    private HttpServletRequest request;
    @PostMapping("/list")
    public R mystocklist(SysUserScok userScok){
        startPage();
        LoginUser loginUser = getLoginUser();
        Long userid = loginUser.getUserid();
        String username = loginUser.getUsername();
        System.out.println("-----------用户id"+userid+"用户名"+username);
        List<SysUserScok> userScokList =userScokService.selectmystockList(userScok,userid);
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(HttpStatus.SUCCESS);
        rspData.setRows(userScokList);
        rspData.setMsg("查询成功");
        rspData.setTotal(new PageInfo(userScokList).getTotal());
        return R.ok(rspData);
    }
}
